package org.javagril.yuetong.service;

import org.javagril.yuetong.bean.Driver;
import org.javagril.yuetong.bean.RespPageBean;
import org.javagril.yuetong.mapper.DriverMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author QingtungTree
 * @Datetime: 2019/12/28
 * @Description:org.javagril.yuetong.service
 * @Version:
 */
@Service
public class DriverService {

    @Autowired
    DriverMapper driverMapper;
        public RespPageBean getAllDrivers(Integer page, Integer size){
            if(page != null && size != null){
                page=(page - 1) * size;
            }

            List<Driver> list = driverMapper.getAllDrivers(page,size);
            Long total = driverMapper.getTotal();
            RespPageBean respPageBean =new RespPageBean();
            respPageBean.setTotal(total);
            respPageBean.setData(list);
            return respPageBean;
        }

}
